<template>
    <div class="box">
      子组件 -- {{ title }} -- 钱包: {{ money }} --车: {{ car }}
      <br>
      <button @click="changeTitle">改标题</button>
      <button @click="changeMoney">搬砖</button>
      <button @click="changeCar">换车</button>
    </div>
  </template>
   
  <script>
  export default {
    // 定义属性接收父组件传值
 
    // props: ['title', 'money', 'car'],
    props: {
      // String, Number, Boolean, Array, Object, Function
      title: String,
      money: Number,
      car: String
    },
    data(){
      return {
        count: 0
      }
    },
    methods: {
      // 1. 修改标题
      changeTitle(){
        // 发射自定义事件, 并传递数据
        this.$emit('changeTitle', '学IT, 来黑马, 月薪过万')
      },
  
      changeMoney(){
        this.$emit('changeMoney', this.money + 15000)
      },
  
      changeCar() {
        this.$emit('changeCar', '问界M9')
      }
    }
  }
  </script>
   
  <style scoped>
  .box{
    width: 400px;
    height: 300px;
    border: 3px solid pink;
    margin: 20px;
  }
  </style>